package Reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;


public class test {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class cls = Class.forName("Reflect.Person");
        Object obj = cls.newInstance();

        Method[]methods = cls.getMethods();

        for(Method method : methods){
            if(method.getModifiers() == Modifier.PUBLIC
            &&
            method.getParameterCount()==0){
                method.invoke(obj);
            }
        }
    }
}
